<template>
  <el-card class="box-card">
    <el-form
      :inline="true"
      :model="formInfo"
      class="demo-form-inline"
      :disabled="show"
    >
      <el-form-item label="一级分类">
        <el-select
          v-model="formInfo.category1Id"
          placeholder="请选择"
          @change="$bus.$emit('hander1', formInfo.category1Id)"
        >
          <el-option
            :label="list.name"
            :value="list.id"
            v-for="list in list1"
            :key="list.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          v-model="formInfo.category2Id"
          placeholder="请选择"
          @change="$bus.$emit('hander2', formInfo.category2Id)"
        >
          <el-option
            :label="list.name"
            :value="list.id"
            v-for="list in list2"
            :key="list.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          v-model="formInfo.category3Id"
          placeholder="请选择"
          @change="$bus.$emit('hander3', formInfo.category3Id)"
        >
          <el-option
            :label="list.name"
            :value="list.id"
            v-for="list in list3"
            :key="list.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script>
export default {
  name: "Category",
  mounted() {
    this.$bus.$on("setfInfo1", this.setfInfo1);
    this.$bus.$on("setfInfo2", this.setfInfo2);
  },
  data() {
    return {
      formInfo: {
        category1Id: "",
        category2Id: "",
        category3Id: "",
      },
    };
  },
  props: ["show", "list1", "list2", "list3", "fInfo"],
  methods: {
    setfInfo1() {
      this.formInfo.category2Id = "";
      this.formInfo.category3Id = "";
    },
    setfInfo2() {
      this.formInfo.category3Id = "";
    },
  },
};
</script>

<style></style>
